<template>
    <div class="main">
        <el-row :gutter="20">
            <el-col :span="6">
                <el-form ref="form" :model="form" label-width="80px">
                    <el-form-item label="旧密码：">
                        <el-input v-model="form.original"></el-input>
                    </el-form-item>
                    <el-form-item label="新密码：">
                        <el-input v-model="form.password"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="submitForm" :loading="loading">提交</el-button>
                    </el-form-item>
                </el-form>
            </el-col>
        </el-row>
        
    </div>
</template>
<script>
export default {
    data(){
        return{
            form:{
                original:null,//旧密码
                password:null,//新密码
            },
            loading:false,
        }
    },
    created(){

    },
    mounted(){

    },
    methods:{
        //提交
        async submitForm(){
            console.log('url------',this.$route.params.id == 'none' ? this.$api + '/v1/login/show' : '')
            if (!this.form.original) {
                this.$message({
                    message: '旧密码格式不正确',
                    type: 'warning'
                });
            }else if(!this.form.password){
                this.$message({
                    message: '新密码格式不正确',
                    type: 'warning'
                });
            }else {
                this.loading = true
                let data = await this.$axios({
                    url: this.$api + '/v1/order/modify',
                    method: 'POST',
                    data:{
                        original:this.form.original,
                        password:this.form.password
                    }
                })
                console.log('修改密码res---------',data)
                this.loading = false
                this.form.original = null
                this.form.password = null
                if (data.data.code ==0) {
                    this.$message({
                        message: data.data.data,
                        type: 'success'
                    });
                    
                }
            }
            
        }
    }
}
</script>